package com.nlscan.ncomgateway.core.manager

import android.content.Context
import android.content.Intent
import com.nlscan.ncomgateway.core.common.AppConst
import com.nlscan.ncomgateway.core.common.AppErrStatus

/**
 * <pre>
 *  author: lin.qing
 *  time  : 2023/8/8
 *  desc  : 应用广播管理类（与三方应用通信）
 *  -- 关于 设备信息、指令
 * </pre>
 */
object AppBroadcastManager {

    /**
     * 发送 接收指令查询结果 广播
     */
//    fun sendReceiveCmdResultBroadcast(
//        context: Context?,
//        address: String?,
//        cmd: String?,
//        status: Int
//    ) {
//        sendReceiveCmdResultBroadcast(context, address, cmd, status, null)
//    }

    fun sendReceiveCmdResultBroadcast(
        context: Context?,
        address: String?,
        cmd: String?,
        status: Int = AppErrStatus.RET_OK,
        result: String? = null
    ) {
        val intent = Intent(AppConst.ACTION_RECEIVE_NLS_CMD_RESULT)
        intent.putExtra(AppConst.EXTRA_DEVICE_ADDRESS, address)
        intent.putExtra(AppConst.EXTRA_NLS_CMD, cmd)
        intent.putExtra(AppConst.EXTRA_STATUS, status)
        result?.let {
            intent.putExtra(AppConst.EXTRA_RESULT, it)
        }
        context?.sendBroadcast(intent)
    }


}